//
//  MMGProduceCollectionViewCell.m
//  DollsVending
//
//  Created by Don on 2017/10/15.
//  Copyright © 2017年 Memego, Inc. All rights reserved.
//

#import "MMGProduceCollectionViewCell.h"
#import "UIColor+HexColor.h"

@interface MMGProduceCollectionViewCell ()

@end
@implementation MMGProduceCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if ((self = [super initWithFrame:frame])) {
        [self setUpUI];
    }
    return self;
    
}

- (void)setUpUI {
    
    [self.produceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_centerY).offset(-20);
        make.left.right.mas_equalTo(self);
        make.height.mas_equalTo(34);
    }];
    
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.produceLabel.mas_bottom).offset(8);
        make.centerX.mas_equalTo(self.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(64, 28));
    }];
    
    
}

#pragma mark - lazy init
- (UILabel *)priceLabel {
    
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.textAlignment = NSTextAlignmentCenter;
        _priceLabel.textColor = [UIColor grayColor];
        _priceLabel.backgroundColor = [UIColor colorWithWhite:0 alpha:0.1];
        _priceLabel.layer.cornerRadius = 2;
        _priceLabel.clipsToBounds = YES;
        _priceLabel.font = [UIFont systemFontOfSize:14];
        _priceLabel.text = @"$12.00";
        
        [self.contentView addSubview:_priceLabel];
    }
    
    return _priceLabel;
}

- (UILabel *)produceLabel {
    
    if (!_produceLabel) {
        _produceLabel = [[UILabel alloc] init];
        _produceLabel.textAlignment = NSTextAlignmentCenter;
        _produceLabel.textColor = [UIColor mmg_colorWithHex:kMMGColorHex_GoldCoinColor];
        _produceLabel.backgroundColor = [UIColor clearColor];
        _produceLabel.layer.cornerRadius = 4;
        _produceLabel.font = [UIFont boldSystemFontOfSize:32];
        _produceLabel.text = @"76";
        _produceLabel.adjustsFontSizeToFitWidth = YES;
        
        [self.contentView addSubview:_produceLabel];
    }
    
    return _produceLabel;
}
@end
